/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.secretaria.saude.model;

import com.secretaria.saude.dominio.ProcedimentoGaia;
import com.secretaria.saude.dominio.ProcedimentoTabWin;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author pablo
 */
public class EquivalenciaModelo extends AbstractTableModel {
    
    public static boolean DEBUG = true;
    
    private String[] columnNames = {"Procedimento Gaia",
                                        "Procedimento TabWin"};
    
        private Object[][] data;
//        {            
//            //{new ProcedimentoGaia(1L, "202020", "Procedimento 1"), new Color(153, 0, 153), false},
//              //  {new ProcedimentoGaia(2L, "303030", "Procedimento 2"), new Color(153, 0, 153), false},
//            {new ProcedimentoGaia(1L, "202020", "Procedimento 1"), new ProcedimentoTabWin(1L,"202020", "Procedimentabwin - 1"), false},
//            {new ProcedimentoGaia(2L, "303030", "Procedimento 2"), new ProcedimentoTabWin(2L,"303030", "Procedimentabwin - 2"), false},
//        };
        
        public EquivalenciaModelo(Object[][] data) {
            this.data = data;
        }
        
        public Object[][] getData() {
            return this.data;
        }
        
        
        public int getColumnCount() {
            return columnNames.length;
        }

        public int getRowCount() {
            return data.length;
        }

        public String getColumnName(int col) {
            return columnNames[col];
        }

        public Object getValueAt(int row, int col) {
            return data[row][col];
        }

        /*
         * JTable uses this method to determine the default renderer/
         * editor for each cell.  If we didn't implement this method,
         * then the last column would contain text ("true"/"false"),
         * rather than a check box.
         */
        public Class getColumnClass(int c) {
            return c == 0 ? ProcedimentoGaia.class : ProcedimentoTabWin.class;
        }

        public boolean isCellEditable(int row, int col) {
            //Note that the data/cell address is constant,
            //no matter where the cell appears onscreen.
            if (col < 1) {
                return false;
            } else {
                return true;
            }
        }

        public void setValueAt(Object value, int row, int col) {

            data[row][col] = value;
            fireTableCellUpdated(row, col);

        }

    
}
